package com.woniuxy.hrms;

import com.woniuxy.hrms.dao.impl.IDeptDaoImpl;
import com.woniuxy.hrms.dao.impl.IEmployeeDaoImplJdbc;
import com.woniuxy.hrms.entity.Dept;
import com.woniuxy.hrms.entity.Employee;

import java.sql.SQLException;
import java.util.Scanner;

/**
 * @program: hrms
 * @description:
 * @create: 2024-08-08 17:41
 **/
public class Main {
    public static void main(String[] args) throws SQLException {
        Dept dept = new Dept(5, "传销部1", "传销员工");
        IDeptDaoImpl deptDao = new IDeptDaoImpl();
//        int add=deptDao.add(dept);
//        int update=deptDao.update(dept);
//        int del=deptDao.delete(5);
//        System.out.println(add);
//        System.out.println(update);
//        System.out.println(del);

//        Employee employee = new Employee(11, "章鱼", "M", 18, "1387777", 8000);
//        IEmployeeDaoImplJdbc iEmployeeDaoImplJdbc = new IEmployeeDaoImplJdbc();
//        int add = iEmployeeDaoImplJdbc.delete(11);
//        //增删改功能已经完成，随时可以在主函数测试
//        System.out.println(add);


        Employee employee = new Employee();
        Scanner scanner = new Scanner(System.in);

        System.out.print("请输入员工ID: ");
        employee.setId(scanner.nextInt());
        scanner.nextLine();//int等数值类型后面加个nextline防止输入端出现问题

        System.out.print("请输入员工姓名: ");
        employee.setName(scanner.nextLine());

        System.out.print("请输入员工年龄: ");
        employee.setAge(scanner.nextInt());
        scanner.nextLine();

        System.out.print("请输入员工性别: ");
        employee.setSex(scanner.nextLine());

        System.out.print("请输入员工电话: ");
        employee.setPhone(scanner.nextLine());

        System.out.print("请输入员工薪水: ");
        employee.setSalary(scanner.nextDouble());
        scanner.nextLine();

        IEmployeeDaoImplJdbc employeeDao = new IEmployeeDaoImplJdbc();

        try {
            int test = employeeDao.add(employee);
            if (test > 0) {
                System.out.println("添加成功！");
            } else {
                System.out.println("添加失败！");
            }
        } catch (SQLException e) {
            e.printStackTrace();
            System.out.println("error");
        }
        scanner.close();
    }
}
